#ifndef __KEYCOMMANDER_HPP__
#define __KEYCOMMANDER_HPP__

#include "UTF8Code.hpp"
#include "../server/TcpConnection.hpp"
#include "QueryResult_Compare.hpp"
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>

using std::string;
using std::set;
using std::vector;
using std::map;
using std::priority_queue;

class KeyRecommander {
public:
    KeyRecommander();
    KeyRecommander(string &, const TcpConnectionPtr &);
    //执行查询
    string doQuery();
    //进行计算
    void statistic();
    //响应客户端请求
    void response();
    //json序列化为string
    string serialize();
    //遇到串需要额外处理
    string serializeNothing();
    //响应客户端
    void respond(); //将消息发送给客户端 
    ~KeyRecommander(){}

private:
    void clearDataMember();

private:
    vector<string> _result; //保存最终结果，关键字
    set<int> _indexID;      //保存索引对应的行号
    string _queryWord;      //查询的关键字
    TcpConnectionPtr _conn;
    priority_queue<QueryResult, vector<QueryResult>, Compare> _resultQue;
};
#endif
